package com.meichis.yndms.vm;

import androidx.lifecycle.MutableLiveData;

import com.meichis.yndms.model.DataTable;
import com.meichis.yndms.model.ProductMarketRate;
import com.meichis.yndms.repository.manager.PartnerProductMarketRateManager;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xmy
 * @title
 * @remake
 * @create 2021-05-08 15:26
 */
public class PartnerProductMarketRateVM extends MyViewModel {

    private MutableLiveData<List<ProductMarketRate>> productMaarketRateList;
    private List<DataTable> dataTableList;
    private MutableLiveData<DataTable> dataTable;


    public MutableLiveData<DataTable> getDataTable() {
        if (dataTable == null) {
            dataTable = new MutableLiveData<>();
            dataTable.setValue(getDataTableList().get(0));
        }
        return dataTable;
    }

    public List<DataTable> getDataTableList() {
        if (dataTableList == null) {
            dataTableList = new ArrayList<>();
            //时间维度：0今日 1昨日 2本周 3本月
            dataTableList.add(new DataTable(1, "当月"));
            dataTableList.add(new DataTable(3, "30天"));
            dataTableList.add(new DataTable(5, "90天"));
        }
        return dataTableList;
    }
    public MutableLiveData<List<ProductMarketRate>> getProductMaarketRateList() {
        if (productMaarketRateList == null){
            productMaarketRateList = new MutableLiveData<>();
            productMaarketRateList.setValue(new ArrayList<>());
        }
        return productMaarketRateList;
    }

    public void GetPartnerProductMarketRate() {
        PartnerProductMarketRateManager.getInstance().GetPartnerProductMarketRate(getShowDialog(),
                getUserInfo().getValue().getOrgId(), getUserInfo().getValue().getId(), getProductMaarketRateList());
    }

}
